package com.cheng.rebuildproject.controller;


import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.cheng.rebuildproject.pojo.ResponseResult;
import com.cheng.rebuildproject.pojo.User;
import com.cheng.rebuildproject.server.UserServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class Register {
    @Autowired
    private UserServer userServer;

    @RequestMapping("/register")
    public ResponseResult register(@RequestBody User user){
        //如果用户user.name名称为空
        if(StringUtils.isBlank(user.getUserName())){
            return new ResponseResult(-101,"参数不正确");
        }

        return userServer.saveUser(user);
    }
}
